package itdep.common.context.spring;

import itdep.common.context.User;
import org.springframework.security.core.GrantedAuthority;

import java.util.Collection;

/**
 * @author Ivan Khalopik
 * @version $Revision: 4 $ $Date: 2010-06-10 13:13:16 +0000 (Thu, 10 Jun 2010) $
 */
public class SpringUser extends org.springframework.security.core.userdetails.User implements User {
	private String remoteHost;
	private String remoteAddress;
	private boolean rememberMe;

	public SpringUser(final String username, final String password, final boolean enabled,
					  final boolean accountNonExpired, final boolean credentialsNonExpired,
					  final boolean accountNonLocked, final Collection<GrantedAuthority> authorities) {
		super(username, password, enabled, accountNonExpired, credentialsNonExpired,
				accountNonLocked, authorities);
	}

	public void setDetails(String remoteHost, String remoteAddress, boolean rememberMe) {
		this.remoteHost = remoteHost;
		this.remoteAddress = remoteAddress;
		this.rememberMe = rememberMe;
	}

	public String getRemoteAddress() {
		return remoteAddress;
	}

	public boolean isRememberMe() {
		return rememberMe;
	}

	public String getName() {
		return getUsername();
	}

	public String getRemoteHost() {
		return remoteHost;
	}

}
